package com.sincebest.fivestar.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.sincebest.fivestar.model.Robot;
import com.sincebest.fivestar.model.RobotWxGroupRela;
import com.sincebest.fivestar.model.WechatGroupMember;

public interface RobotMapper {
	
	public Robot getRobotByImId(@Param("imId")String imId);
	
	public Robot getImIdById(@Param("robotId")Integer robotId);
	
	public int addRobot(@Param("imId")String imId);
	
	public int updateRobot(@Param("id")Integer id,@Param("imId") String imId);
	
	public int addRobotWxGroupRela(@Param("robotId")Integer robotId,@Param("weChatGroupId") String weChatGroupId, 
			@Param("groupOwnerId")String groupOwnerId,@Param("houseId") String houseId);
	
	public int updateWxGroupRela(@Param("rela") RobotWxGroupRela RobotWxGroupRela);
	
	public RobotWxGroupRela selectRobotWxGroupRela(@Param("weChatGroupId") String weChatGroupId);
	
	public RobotWxGroupRela selectRobotWxGroupRelaByHouseId(@Param("houseId") String houseId);
	
	/**
	 * 使用了 ON DUPLICATE KEY UPDATE 语句， 依赖于 memberId 和wechatGroupId 组合的唯一索引
	 * @param members
	 */
	public void addWxGroupMembers(@Param("list") List<WechatGroupMember> members);
	
	public void deleteWxGroupMembers(@Param("list") List<WechatGroupMember> members, @Param("weChatGroupId") String weChatGroupId);
	
	public void updateGroupMemberInfo(@Param("member") WechatGroupMember member);
	
	public void updateGroupMemberWxId(@Param("oldMemberId") String oldMemberId, @Param("memberId") String newMemberId);
    
	public WechatGroupMember getWxGroupMemberInfo(@Param("memberId") String memberId);
}